import axios from "axios";

//配置项
const axiosOption={
    baseUrl:"/api",
    // baseUrl:"http://54.163.5.153:8080",
    timeout:5000
}

//创建一个单例
const instance=axios.create(axiosOption);

//创建请求拦截器
instance.interceptors.request.use(function (config)
{
    config.headers.Authorization = localStorage.getItem('token')
    return config;
},function (error){
    //请求错误
    return Promise.reject(error);
});

//添加响应拦截器
instance.interceptors.response.use(function (response){
    //响应数据
    return response.data;
},function (error){
    return Promise.reject(error);
});

export default instance;

